<?php
namespace Admin\Controller;

use Think\Controller;

class LoginController extends controller
{

    public function login()
    {
        $this->display();
    }

    public function dologin()
    {
        $condition = array(
            'adminname' => $_POST['adminname'],
             'password'=>$_POST['adminpassword']
         //   'password' => md5(I('post.password'))
        );
        var_dump($condition);
        $adminModel = M('Admin');
        $admin = $adminModel->where($condition)->find();
        
        if ($admin) {
            // 是合法用户，设置session
            session('admin', $admin);
            $this->redirect('Index/users');
        } else {
            $this->error('用户名或密码错误');
        }
    }

    public function logout()
    {
        session('admin', null);
      //  exit();
        $this ->redirect('login');
    }
}
